/*
 * @Author: your name
 * @Date: 2020-10-05 20:04:13
 * @LastEditTime: 2020-10-05 21:05:45
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \shuixiang\lib\main.dart
 */
import 'package:flutter/material.dart';
import 'package:flutter_swiper/flutter_swiper.dart';

void main() {
  
  runApp(MyApp());
  
}

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: '',
      theme: ThemeData(
        primarySwatch: Colors.red,
        visualDensity: VisualDensity.adaptivePlatformDensity,
      ),
    debugShowCheckedModeBanner:false,
      home: MyHomePage(title: ''),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);

  final String title;

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  List<AssetImage> imgs = [
    //建立了一个图片数组
    AssetImage("assets/images/index.png"),
    AssetImage("assets/images/index2.png"), AssetImage("assets/images/index3.png"),
    AssetImage("assets/images/index4.png"), AssetImage("assets/images/index5.png"),
  ];
  @override
  Widget build(BuildContext context) {
    return Scaffold(
        body: Center(
            child: Swiper(
      itemBuilder: (BuildContext context, int index) {
        //条目构建函数传入了index,根据index索引到特定图片
        return  Container(
              width: double.infinity,
              height: double.infinity,
              decoration: BoxDecoration(
                  image: DecorationImage(
                      image: imgs[index],
                      fit: BoxFit.cover)),);
      },
      loop:false,
      itemCount: imgs.length,
      autoplay: false,
      // pagination: new SwiperPagination(builder: SwiperPagination.fraction ), //这些都是控件默认写好的,直接用
      control: new SwiperControl(
        color: Colors.transparent,
      ),
    )));
  }
}
